package com.example.homemodule.view.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.example.homemodule.viewmodel.HomeViewModel;
import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.yilijk.base.utils.ALog;

public class DrugListXRecyclerView extends XRecyclerView {
    public DrugListXRecyclerView(Context context) {
        super(context);
    }

    public DrugListXRecyclerView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public DrugListXRecyclerView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }


    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        ALog.e("oakkk", "child intercept touch event: " + ev.getAction());

        return super.onInterceptTouchEvent(ev);
//        return true;
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        ALog.e("oakkk", "child dispatch touch event: " + ev.getAction());
//        if (isDrugsTlFixed) {
////            getParent().requestDisallowInterceptTouchEvent(true);
//        } else {
//            getParent().requestDisallowInterceptTouchEvent(false);
////            return false;
//        }
        return super.dispatchTouchEvent(ev);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        ALog.e("oakkk", "child on touch event: " + ev.getAction());

        if (!HomeViewModel.isDrugsTlFixed){
            super.onTouchEvent(ev);
            getParent().requestDisallowInterceptTouchEvent(false);
            return false;
        }
        return super.onTouchEvent(ev);

    }
}
